package com.baishancloud.log;

import org.junit.Test;

import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;

/**
 * @author ziqiang.wang
 * @date 2022/4/8 10:58
 */
public class AppTestJ {

    @Test
    public void test1() throws Exception {
        byte[] buffer = new byte[10];
        FileInputStream input = new FileInputStream("/Users/wangziqiang/workspace/work/log/thunderfury-flink-maven/common/src/test/scala/com/baishancloud/log/AppTestJ.java");
        StringBuilder stringBuilder = new StringBuilder();
        while (true) {
            int read = input.read(buffer);
            if (read < 10) {
                if (read > 0) {
                    byte[] bytes = new byte[read];
                    for (int index = 0; index < read; index++) {
                        bytes[index] = buffer[index];
                    }
                    stringBuilder.append(new String(bytes, StandardCharsets.UTF_8));
                    break;
                } else {
                    break;
                }
            } else {
                stringBuilder.append(new String(buffer, StandardCharsets.UTF_8));
            }
        }
        System.out.print(stringBuilder);
    }

}